from django.conf.urls import url
from django.contrib import admin
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_admin.views.skus import SKUViewSet
from .views import increment, users, skus, spus, specs, options, orders, channels, brands, images, permission, group, \
    admin
from rest_framework.routers import DefaultRouter

urlpatterns = [
    # JWT 登录
    url(r'^authorizations/$', obtain_jwt_token),
    # 统计用户总量
    url(r'^statistical/total_count/$', increment.UseTotalCountView.as_view()),
    # 当天注册用户总量
    url(r'^statistical/day_increment/$', increment.UseTodayTotalCountView.as_view()),
    # 日活跃用户
    url(r'^statistical/day_active/$', increment.UseActiveTotalCountView.as_view()),
    # 日下单用户
    url(r'^statistical/day_orders/$', increment.UserOrderCountView.as_view()),
    # 月增用户
    url(r'^statistical/month_increment/$', increment.UserMonthCountView.as_view()),
    # 日商品类别访问量
    url(r'^statistical/goods_day_views/$', increment.GoodsVisitView.as_view()),
    # ------------------用户-------------------
    # 获取用户
    url(r'^users/$', users.UserView.as_view()),
    # skus 查询三级分类信息
    url(r'^skus/categories/$', skus.SKUViewSet.as_view({'get': 'categories'})),
    #  skus 查询spu表数据
    url(r'^goods/simple/$', skus.SKUViewSet.as_view({'get': 'goodssimple'})),

    # 查询spu商品的所有规格
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUViewSet.as_view({'get': 'spuspecification'})),

    # -------------------------------规格选项表路由--------------------------------------
    url(r'^goods/specs/simple/$', options.SpecificationOptionView.as_view({'get': 'simple'})),

    #  brand 查询品牌
    url(r'^goods/brands/simple/$', spus.SPUSViewSet.as_view({'get': 'brands'})),

    #  查询一级分类信息
    url(r'^goods/channel/categories/$', spus.SPUSViewSet.as_view({'get': 'channel'})),

    #  查询二三级分类信息
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.SPUSViewSet.as_view({'get': 'channels'})),
    # -------------------------------订单表路由--------------------------------------
    # url(r'^orders/$', orders.OrdersView.as_view()),
    #  频道
    url(r'^goods/categories/$', channels.ChannelViewSet.as_view({'get': 'categories'})),
    url(r'^goods/channel_types/$', channels.ChannelViewSet.as_view({'get': 'channel_type'})),

    #  sku_image
    url(r'^skus/simple/$', images.ImagesViewSet.as_view({'get': 'sku_image'})),
    # 权限类型
    url(r'^permission/content_types/$', permission.PermissionViewSet.as_view({'get': 'content_type'})),
    # 用户组权限
    url(r'^permission/simple/$', group.GroupViewSet.as_view({'get': 'simple'})),
    # 管理员中获取用户组
    url(r'^permission/groups/simple/$', admin.AdminViewSet.as_view({'get': 'simple'})),

]

# skus
router = DefaultRouter()
router.register('skus/images', images.ImagesViewSet, base_name='images')
# skus
router.register('skus', skus.SKUViewSet, base_name='skus')
# ------------------------------ SPUSpecification表路由-----------------------------------
router.register('goods/specs', specs.SPUSpecificationView, base_name='specs')
# ------------------------------ 频道表路由-----------------------------------
router.register('goods/channels', channels.ChannelViewSet, base_name='channels')
# ------------------------------ 品牌表路由-----------------------------------
router.register('goods/brands', brands.BrandViewSet, base_name='brands')
# spus
router.register('goods', spus.SPUSViewSet, base_name='spus')
# ------------------------------ 规格选项表路由------------------------------------------------
router.register('specs/options', options.SpecificationOptionView, base_name='options')
router.register('orders', orders.OrderViewSet, base_name='orders')
# 权限
router.register('permission/perms', permission.PermissionViewSet, base_name='perms')
# 用户组
router.register('permission/groups', group.GroupViewSet, base_name='groups')
# 管理员
router.register('permission/admins', admin.AdminViewSet, base_name='admin')

urlpatterns += router.urls
